home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / footiefox-2.1.2-fx.xpi / chrome / footiefox.jar / content / footiefox / options.js < prev    next >
Text File  |  2008-07-01  |  68KB  |  2,025 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2. EULA
  3.  
  4. Terms of use
  5.  
  6. The FootieFox - Boris Ruf and Jan Schulz-Hofen GbR (ôFootieFoxö) grants you the non-transferable, non-exclusive and revocable right to use the FootieFox Software free of charge, for your personal, non-commercial use only, subject to this licensing agreement. However, you may not use the FootieFox Software in any manner that could overburden, impair or damage the FootieFox Web Service (e.g., you are not allowed to use the FootieFox Software in an automated manner).
  7.  
  8. Intellectual Property
  9.  
  10. After obtaining written consent of FootieFox by e-mail (contact@footiefox.com) you are permitted to offer the FootieFox Software as a whole, without any modifications and free of charge for download on your website other than footiefox.com. You may not lease, rent or sell the FootieFox Software or the information presented to you through the FootieFox Software. Furthermore, you may not sublicense or otherwise transfer any right in the FootieFox Software. You agree not to modify, adapt, translate, decompile, reverse engineer, disassemble or otherwise attempt to derive source code from the FootieFox Software. Distributing or creating derivative works based on the FootieFox Software is expressly not permitted. You also agree to not remove, obscure, or alter FootieFoxÆ and or any third partyÆs copyright notice, trademarks, or other proprietary rights notices presented through or contained in the FootieFox Software.
  11.  
  12. Disclaimer of Warranties
  13.  
  14. The FootieFox Software is provided free of charge and with no warranties whatsoever. FootieFox and any third party who provides its service through the FootieFox Software disclaim any responsibility for any harm resulting from the use of the FootieFox Software and/or any service provided by any third party through the FootieFox Software.
  15.  
  16. THE FOOTIEFOX SOFTWARE IS PROVIDED ôAS ISö WITH ALL FAULTS AND WITH NO WARRANTIES WHATSOEVER. FOOTIEFOX EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES THAT THE PRODUCT IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE AND NON-INFRINGING. FOOTIEFOX AND THIRD PARTIES WHO PROVIDE SERVICE THROUGH THE FOOTIEFOX SOFTWARE DISCLAIM ANY WARRANTIES REGARDING THE SECURITY, RELIABILITY, TIMELINESS, AND PERFORMANCE OF THE FOOTIEFOX SOFTWARE AND/OR THE INFORMATION PRESENTED TO YOU THROUGH THE FOOTIEFOX SOFTWARE.
  17.  
  18. YOU UNDERSTAND AND AGREE THAT YOU BEAR ENTIRE RISK AS TO THE FITNESS, THE QUALITY AND THE PERFORMANCE OF THE PRODUCT AND THAT YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGES TO YOUR COMPUTER SYSTEM OR LOSS OF DATA THAT RESULTS FROM THE DOWNLOAD OR USE OF THE FOOTIEFOX SOFTWARE. IN SOME COUNTRIES THE EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES IS NOT ALLOWED, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
  19.  
  20. Limitation of Liability
  21.  
  22. TO THE EXTENT PERMITTED BY LAW, FOOTIEFOX OR ANY THIRD PARTY WILL NOT BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES ARISING OUT OF OR IN ANY WAY RELATING TO THIS LICENSING AGREEMENT OR THE USE OF OR INABILITY TO USE THE FOOTIEFOX SOFTWARE, INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, LOST PROFITS, LOSS OF DATA, AND COMPUTER FAILURE OR MALFUNCTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE THEORY (E.G. CONTRACT OR TORT) UPON WHICH SUCH CLAIM IS BASED. IN SOME COUNTRIES THE EXCLUSION OR LIMITATION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES IS NOT ALLOWED, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
  23.  
  24. Other Terms
  25.  
  26. The present license agreement will be governed by and construed in accordance with the laws of the Federal Republic of Germany and shall not be governed by the United Nations Convention on the International Sale of Goods. The courts of Berlin shall have exclusive jurisdiction.
  27.  
  28. If any part of this license agreement is held invalid or unenforceable, that part will be construed to reflect the partiesÆ original intent, and the remaining portions will remain in full force and effect.
  29.  
  30. * ***** END LICENSE BLOCK ***** */
  31.  
  32.  
  33.  
  34.  
  35. function ffOptions() {
  36.  
  37.     ffOptions.prototype.onLoad = onLoad;
  38.     ffOptions.prototype.onUnload = onUnload;
  39.  
  40.  
  41.  
  42.     ffOptions.prototype.getLeague = getLeague;
  43.  
  44.  
  45.     ffOptions.prototype.populateLeaguesTree = populateLeaguesTree;
  46.  
  47.     ffOptions.prototype.addLeaguesToListBox = addLeaguesToListBox;
  48.     ffOptions.prototype.onLeaguesKeyUp = onLeaguesKeyUp;
  49.     ffOptions.prototype.onLeaguesAddCmd = onLeaguesAddCmd;
  50.     ffOptions.prototype.onLeaguesMoveUpCmd = onLeaguesMoveUpCmd;
  51.     ffOptions.prototype.onLeaguesMoveDownCmd = onLeaguesMoveDownCmd;
  52.     ffOptions.prototype.onLeaguesRemoveCmd = onLeaguesRemoveCmd;
  53.     ffOptions.prototype.removeLeaguesFavorite = removeLeaguesFavorite;
  54.     ffOptions.prototype.leaguesTreeItemClicked = leaguesTreeItemClicked;
  55.  
  56.     ffOptions.prototype.addTeamsToListBox = addTeamsToListBox;
  57.     ffOptions.prototype.updateTeamsSearchList = updateTeamsSearchList;
  58.     ffOptions.prototype.onTeamsKeyUp = onTeamsKeyUp;
  59.     ffOptions.prototype.onTeamsAddCmd = onTeamsAddCmd;
  60.     ffOptions.prototype.onTeamsRemoveCmd = onTeamsRemoveCmd;
  61.     ffOptions.prototype.onTeamsMoveUpCmd = onTeamsMoveUpCmd;
  62.     ffOptions.prototype.onTeamsMoveDownCmd = onTeamsMoveDownCmd;
  63.     ffOptions.prototype.openTeamInformationSearchbox = openTeamInformationSearchbox;
  64.     ffOptions.prototype.openTeamInformationFavorites = openTeamInformationFavorites;
  65.  
  66.     ffOptions.prototype.removeTeamsFavorite = removeTeamsFavorite;
  67.     ffOptions.prototype.teamsTreeItemClicked = teamsTreeItemClicked;
  68.  
  69.     ffOptions.prototype.callWhatsOn = callWhatsOn;
  70.     ffOptions.prototype.callManuallyUpdateTeamsList = callManuallyUpdateTeamsList;
  71.     ffOptions.prototype.teamsListUpdated = teamsListUpdated;
  72.     
  73.     ffOptions.prototype.applyLanguagePackage = applyLanguagePackage;
  74.     ffOptions.prototype.updateLocale = updateLocale;
  75.  
  76.  
  77.     ffOptions.prototype.doOK = doOK;
  78.     ffOptions.prototype.enableAlarmSoundsGroup = enableAlarmSoundsGroup;
  79.     ffOptions.prototype.enableAlarmSliderGroup = enableAlarmSliderGroup;
  80.     ffOptions.prototype.ConfigureAlarmPanel = ConfigureAlarmPanel;
  81.     ffOptions.prototype.browseAlarmSoundFiles = browseAlarmSoundFiles;
  82.     ffOptions.prototype.PreviewAlarmSound = PreviewAlarmSound;
  83.  
  84.     ffOptions.prototype.onRotationIntervalChanged = onRotationIntervalChanged;
  85.     
  86.     
  87.     ffOptions.prototype.partnerSelect = partnerSelect;
  88.  
  89.  
  90.  
  91.  
  92.     this.standardsound = "chrome://footiefox/skin/goal.wav";
  93.     this.availableLeagues = null;
  94.     this.availableTeams = null;
  95.     this.leaguesTree = null;
  96.     this.teamsTree = null;
  97.     this.favoriteLeaguesList = null;
  98.     this.favoriteTeamsList = null;
  99.     this.prefNode = null;
  100.     this.favoriteLeaguesChanged = false;
  101.     this.rotationIntervalChanged = false;
  102.     this.redirectURL = "http://redirect.footiefox.com/";
  103.     
  104.     
  105.  
  106.  
  107.     function League(leagueId, leagueName, leagueRank, leagueCountry, leagueShort, intlTitle)
  108.     {
  109.         this.id = leagueId;
  110.         this.title = leagueName;
  111.         this.rank = leagueRank;
  112.         this.country = leagueCountry;
  113.         this.countryshort = leagueShort;
  114.         this.intltitle = intlTitle;
  115.  
  116.  
  117.     }
  118.     
  119.     function Team(teamId, leagueId, teamName)
  120.     {
  121.         this.id = teamId;
  122.         this.leagueId = leagueId;
  123.         this.title = teamName;
  124.  
  125.     }
  126.  
  127.  
  128.     function getLeague(id) {
  129.  
  130.  
  131.         for (var i=0; i < this.availableLeagues.length; i++)
  132.         {
  133.             var currentLeague = this.availableLeagues[i];
  134.             var currentId = currentLeague.id;
  135.  
  136.             if (id == currentId ) {
  137.                 return currentLeague;
  138.             }
  139.  
  140.         }
  141.         return null;
  142.  
  143.     }
  144.  
  145.         function getTeam(id) {
  146.  
  147.         for (var i=0; i < ffOptions.availableTeams.length; i++)
  148.         {
  149.             var currentTeam = ffOptions.availableTeams[i];
  150.  
  151.             var currentId = currentTeam.id;
  152.  
  153.             if (id == currentId ) {
  154.                 return currentTeam;
  155.             }
  156.  
  157.         }
  158.         return null;
  159.  
  160.     }
  161.     
  162.     function callWhatsOn() {
  163.     
  164.         this.favoriteLeaguesChanged = true;
  165.         document.documentElement.acceptDialog();
  166.         
  167.         
  168.     }
  169.     
  170.     function callManuallyUpdateTeamsList() {
  171.         
  172.         Components.classes["@mozilla.org/observer-service;1"]
  173.                  .getService(Components.interfaces.nsIObserverService)
  174.                  .notifyObservers(null, "footiefoxManuallyUpdateTeamsList", "");
  175.                  
  176.         var button = document.getElementById("ff_options_updateteams_button");
  177.         button.setAttribute("disabled","true");
  178.         var spinner = document.getElementById("ff_options_updateteams_spinner");
  179.         spinner.setAttribute("collapsed", "false");
  180.         var updating = document.getElementById("ff_options_updateteams_updating");
  181.         updating.setAttribute("value", "Updating ...");
  182.         updating.setAttribute("collapsed", "false");
  183.         
  184.                 
  185.     }
  186.     
  187.     function teamsListUpdated() {
  188.     
  189.         var button = document.getElementById("ff_options_updateteams_button");
  190.         button.setAttribute("disabled","false");
  191.         var spinner = document.getElementById("ff_options_updateteams_spinner");
  192.         spinner.setAttribute("collapsed", "true");
  193.         var updating = document.getElementById("ff_options_updateteams_updating");
  194.         updating.setAttribute("value", "Successfully updated!");
  195.         ffOptions.availableTeams = getAvailableTeams();
  196.         
  197.         //kuku
  198.     }
  199.  
  200.     function getTeams(leagueId)
  201.     {
  202.         var teamsArray = new Array();
  203.  
  204.         for (var i=0; i < ffOptions.availableTeams.length; i++)
  205.         {
  206.             var currentTeam = ffOptions.availableTeams[i];
  207.             var currentLeagueId = currentTeam.leagueId;
  208.  
  209.             if (currentLeagueId == leagueId )
  210.                 teamsArray.push(currentTeam);
  211.  
  212.         }
  213.  
  214.         return teamsArray;
  215.  
  216.     }
  217.  
  218.     function onLoad()
  219.     {
  220.     
  221.  
  222.         this.myObservers = new myObservers();
  223.                 
  224.         
  225.         var gDBTPrefService = Components.classes["@mozilla.org/preferences-service;1"]
  226.                 .getService(Components.interfaces.nsIPrefService);
  227.  
  228.         this.prefNode = gDBTPrefService.getBranch("extensions.footiefox.");
  229.         
  230.         if (this.prefNode.prefHasUserValue("tempdir"))
  231.             this.tmpDir = this.prefNode.getCharPref("tempdir");
  232.         else {
  233.             this.tmpDir = "";
  234.             this.prefNode.setCharPref("tempdir","");
  235.         }
  236.  
  237.         this.dictionary = document.getElementById("stringbundle_dictionary");
  238.         
  239.         this.partners = document.getElementById("partners-data-bundle");
  240.  
  241.         this.leaguesTree = document.getElementById("ff-leagues-tree");
  242.         
  243.         var leaguesDataBundleUpdated = document.getElementById("leagues-data-bundle-updated");
  244.  
  245.         if (inCache("leagues.dat")) {
  246.         //check if local leagues.dat valid
  247.             try {
  248.  
  249.                 leaguesDataBundleUpdated.setAttribute("src", "file://" + this.tmpDir + "leagues.dat");
  250.                 var leaguesDataString = leaguesDataBundleUpdated.getString(1);
  251.  
  252.             //leagues.dat maybe corrupt
  253.             } catch (e) {
  254.                                    footiefox_d("leagues.dat corrupt");
  255.                                    leaguesDataBundleUpdated.removeAttribute("src");
  256.  
  257.             }
  258.         }
  259.  
  260.         var loc = this.prefNode.getCharPref("locale");
  261.         applyLanguagePackage(loc);        
  262.                 
  263.  
  264.         this.availableLeagues = getAvailableLeagues();
  265.  
  266.         this.favoriteLeaguesList = document.getElementById("ff-favoriteleagues-box");
  267.         this.favoriteTeamsList = document.getElementById("ff-favoriteteams-box");
  268.  
  269.         var allLeagues = this.availableLeagues;
  270.         populateLeaguesTree ( allLeagues );
  271.  
  272.  
  273.  
  274.         //LEAGUES-Tab:
  275.  
  276.  
  277.         var leaguesToFollow = this.prefNode.getCharPref("leaguestofollow");
  278.  
  279.         if (leaguesToFollow!="") {
  280.             leaguesToFollow = leaguesToFollow.split(",");
  281.  
  282.                 var leagues = new Array();
  283.                 for (var x=0; x<leaguesToFollow.length-1; x++){
  284.                         leagues.push(this.getLeague(leaguesToFollow[x]));
  285.                 }
  286.  
  287.             this.addLeaguesToListBox(leagues);
  288.         }
  289.  
  290.         //TEAMS-Tab:
  291.  
  292.         var teamsDataBundleUpdated = document.getElementById("teams-data-bundle-updated");
  293.  
  294.         if (inCache("teams.dat")) {
  295.         //check if local teams.dat valid
  296.             try {
  297.  
  298.                 teamsDataBundleUpdated.setAttribute("src", "file://" + this.tmpDir + "teams.dat");
  299.                 var teamsDataString = teamsDataBundleUpdated.getString(11);
  300.  
  301.  
  302.  
  303.             //teams.dat maybe corrupt
  304.             } catch (e) {
  305.                 footiefox_d("teams.dat corrupt");
  306.                 teamsDataBundleUpdated.removeAttribute("src");
  307.  
  308.             }
  309.             }
  310.  
  311.  
  312.         this.teamsTree = document.getElementById("ff-teams-tree");
  313.         this.availableTeams = getAvailableTeams();
  314.  
  315.  
  316.         var teamsToFollow = this.prefNode.getCharPref("teamstofollow");
  317.         if (teamsToFollow!="") {
  318.             teamsToFollow = teamsToFollow.split(",");
  319.  
  320.                 var teams = new Array();
  321.                 for (var x=0; x<teamsToFollow.length-1; x++) {
  322.                                 var cTeam = getTeam(teamsToFollow[x]);
  323.                                 if (cTeam != null )
  324.                            teams.push( cTeam );
  325.                 }
  326.  
  327.             this.addTeamsToListBox(teams);
  328.         }
  329.  
  330.         //ALARM-Tab:
  331.  
  332.         //Slider
  333.         var alarmshowslidercbox = document.getElementById("ff_options_alarm_activated");
  334.         var showSlider = this.prefNode.getBoolPref("showslider");
  335.         var alertmode = this.prefNode.getCharPref("alertmode");
  336.  
  337.         var radiogroupAlertmode = document.getElementById("radiogroup-alertmode");
  338.  
  339.                 radiogroupAlertmode.selectedItem = radiogroupAlertmode.getElementsByAttribute("value", String(alertmode))[0];
  340.  
  341.         if (!showSlider) {
  342.  
  343.             radiogroupAlertmode.disabled = true;
  344.         }
  345.                 alarmshowslidercbox.setAttribute("checked", showSlider);
  346.  
  347.                 var displayduration = this.prefNode.getIntPref("sliderdisplayduration");
  348.                 var textbox_duration = document.getElementById("textbox-alertsliderseconds");
  349.                 textbox_duration.value = displayduration;
  350.  
  351.  
  352.         //Sound
  353.         var ffAlertsound_cb = document.getElementById("ff_options_alarm_sound_activated");
  354.         var ffAlertSound_sounds_rgroup = document.getElementById("alarm-sounds-rgroup");
  355.         var ffAlertSound_sounds_preview = document.getElementById("ff_options_alarm_sound_previewbutton");
  356.  
  357.         var playalarm_checked = this.prefNode.getBoolPref("playalarm");
  358.         ffAlertsound_cb.setAttribute("checked", playalarm_checked);
  359.  
  360.             var ffAlertSound_customsound_tbox = document.getElementById("alarm-customfile-tbox");
  361.         if (!playalarm_checked) {
  362.  
  363.             ffAlertSound_sounds_rgroup.disabled = true;
  364.             ffAlertSound_customsound_tbox.disabled = true;
  365.             ffAlertSound_sounds_preview.disabled = true;
  366.         }
  367.  
  368.         var ffAlertsoundtype = this.prefNode.getCharPref("alarmtype");
  369.         if (ffAlertsoundtype=="standard")
  370.             ffAlertSound_customsound_tbox.disabled = true;
  371.  
  372.             var browseButton = document.getElementById('ff_options_alarm_sound_browsebutton');
  373.                 if (ffAlertsoundtype=="custom")
  374.                     browseButton.disabled = false;
  375.  
  376.         ffAlertSound_sounds_rgroup.selectedItem = ffAlertSound_sounds_rgroup.getElementsByAttribute("value", ffAlertsoundtype)[0];
  377.  
  378.             var ffAlertsoundfile = this.prefNode.getCharPref("alarmfile");
  379.  
  380.             ffAlertSound_customsound_tbox.value = ffAlertsoundfile;
  381.  
  382.  
  383.  
  384.  
  385.         //APPEARANCE-Tab:
  386.  
  387.         //Rotation
  388.         var checkboxdiscretemode = document.getElementById("ff_options_appearance_discretemode_hideif");
  389.  
  390.         var discretemode = this.prefNode.getBoolPref("discretemode");
  391.  
  392.         checkboxdiscretemode.setAttribute("checked", discretemode);
  393.  
  394.         var rotationintervall = this.prefNode.getIntPref("rotationintervall");
  395.                 var textbox_rotation = document.getElementById("textbox-rotation");
  396.                 textbox_rotation.value = rotationintervall;
  397.  
  398.                 var rotationscope = this.prefNode.getCharPref("rotationscope");
  399.         var radiogroupRotationscope = document.getElementById("radiogroup-rotationscope");
  400.  
  401.         radiogroupRotationscope.selectedItem = radiogroupRotationscope.getElementsByAttribute("value", String(rotationscope))[0];
  402.  
  403.         //Menu Items
  404.                 var checkboxmenuitemsshowscores = document.getElementById("ff_options_appearance_menulayout_scores");
  405.           var showscores = this.prefNode.getBoolPref("menuitemsshowscores");
  406.         checkboxmenuitemsshowscores.setAttribute("checked", showscores);
  407.  
  408.                 var checkboxmenuitemsshowdate = document.getElementById("ff_options_appearance_menulayout_date");
  409.           var showdate = this.prefNode.getBoolPref("menuitemsshowdate");
  410.         checkboxmenuitemsshowdate.setAttribute("checked", showdate);
  411.  
  412.  
  413.         var menulayout = this.prefNode.getCharPref("menulayout");
  414.         var radiogroupMenulayout = document.getElementById("radiogroup-menulayout");
  415.         radiogroupMenulayout.selectedItem = radiogroupMenulayout.getElementsByAttribute("value", String(menulayout))[0];
  416.         
  417.         var colorScheduled = this.prefNode.getCharPref("color.scheduled");
  418.         var textboxScheduled = document.getElementById("textbox-color-scheduled");
  419.         textboxScheduled.value = colorScheduled;
  420.         var colorPickerScheduled = document.getElementById("color_scheduled");
  421.         colorPickerScheduled.color = colorScheduled;
  422.         
  423.         var colorActive = this.prefNode.getCharPref("color.active");
  424.         var textboxActive = document.getElementById("textbox-color-active");
  425.         textboxActive.value = colorActive;
  426.         var colorPickerActive = document.getElementById("color_active");
  427.         colorPickerActive.color = colorActive;
  428.         
  429.         var colorFinished = this.prefNode.getCharPref("color.finished");
  430.         var textboxFinished = document.getElementById("textbox-color-finished");
  431.         textboxFinished.value = colorFinished;
  432.         var colorPickerFinished = document.getElementById("color_finished");
  433.         colorPickerFinished.color = colorFinished;
  434.         
  435.         
  436.         
  437.         //LANGUAGE-Tab:
  438.         
  439.         this.currentPartner = parseInt(this.prefNode.getCharPref("partner"));
  440.         
  441.         var loc = this.prefNode.getCharPref("locale");
  442.         
  443.         var dropdown_locale = document.getElementById("menulist_language_package");
  444.         
  445.         dropdown_locale.selectedItem = dropdown_locale.getElementsByAttribute("value", String(loc))[0];
  446.         
  447.         var partner_statusbar = document.getElementById("ff_options_language_partner_statusbar");
  448.         partner_statusbar.setAttribute("checked", this.prefNode.getBoolPref("partner.statusbarlabel"));       
  449.  
  450.         var partnerbox = document.getElementById("partner_logo_box");
  451.         
  452.         var partner = null;
  453.         
  454.         var arrow_left = document.getElementById("autorepeat-left");
  455.         var arrow_right = document.getElementById("autorepeat-right");
  456.             
  457.         var partnersEnum = this.partners.strings;
  458.         var index = -1;
  459.         
  460.         while (partnersEnum.hasMoreElements()) {
  461.         
  462.                 try {
  463.  
  464.                 var element = partnersEnum.getNext();
  465.  
  466.                 var key = element.QueryInterface(Components.interfaces.nsIPropertyElement).key;
  467.                 var value = element.QueryInterface(Components.interfaces.nsIPropertyElement).value;
  468.                     
  469.                 if (value.split(":")[0]==loc) {
  470.                     index = key;
  471.                     break;
  472.                 }
  473.  
  474.             } catch(ex){
  475.                         footiefox_d(ex); continue;
  476.             }
  477.         }
  478.  
  479.     
  480.         var partnerNum = this.prefNode.getCharPref("partner");
  481.             
  482.         try {
  483.         //locale partner 
  484.         
  485.             var partner = this.partners.getString(index).split(":")[1];
  486.             
  487.             arrow_left.setAttribute("hidden","true");
  488.             arrow_right.setAttribute("hidden","true");
  489.             
  490.            
  491.             
  492.         
  493.         } catch (e) {
  494.             //no locale partner
  495.             var box = document.getElementById("nolocalepartner");
  496.             box.setAttribute("hidden","false");
  497.             
  498.             
  499.         
  500.             arrow_left.setAttribute("hidden","false");
  501.             arrow_right.setAttribute("hidden","false");
  502.             
  503.             arrow_left.setAttribute("disabled","true");
  504.             arrow_right.setAttribute("disabled","true");
  505.           
  506.             
  507.         
  508.         }
  509.         
  510.         partnerbox.setAttribute("src", "chrome://footiefox/skin/"+partnerNum+"/statusbar.png");
  511.  
  512.         var partner_toolbarbutton = document.getElementById("ff_options_language_partner_toolbarbutton");
  513.         var buttonsString = this.prefNode.getCharPref("partner.toolbarbuttons");
  514.         
  515.         var buttonsArray = buttonsString.split(":");
  516.         
  517.         var toolbar_listbox = document.getElementById("ff_options_partner_toolbar_listbox");
  518.         
  519.         partnersEnum = this.partners.strings;
  520.         while (partnersEnum.hasMoreElements()) {
  521.         
  522.             try {
  523.  
  524.                 var element = partnersEnum.getNext();
  525.  
  526.                 var key = element.QueryInterface(Components.interfaces.nsIPropertyElement).key;
  527.                 var value = element.QueryInterface(Components.interfaces.nsIPropertyElement).value;
  528.                 
  529.                 //var partner_name = value.split(":")[1];
  530.                 var partner_url = value.split(":")[1];
  531.                 
  532.                 var listitem = document.createElement("richlistitem");
  533.                 var img = document.createElement("image");
  534.                 img.setAttribute("src", "chrome://footiefox/skin/"+key+"/button.png");
  535.                 img.setAttribute("style", "margin:10px");
  536.                 var cb = document.createElement("checkbox");    
  537.                 cb.setAttribute("id", "ff_options_language_partner_toolbarbutton_"+key);
  538.                 cb.setAttribute("label", partner_url);
  539.                 for (var j=0; j<buttonsArray.length;j++) {
  540.  
  541.                     if (buttonsArray[j] == key ) {
  542.                         cb.setAttribute("checked", "true");
  543.                         break;
  544.                     }
  545.                 }
  546.                 
  547.                 listitem.appendChild(img);
  548.                 listitem.appendChild(cb);
  549.                 
  550.                 toolbar_listbox.appendChild(listitem);              
  551.                 
  552.  
  553.             } catch(ex){
  554.                         footiefox_d(ex); continue;
  555.             }
  556.         }
  557.         
  558.         //update tab
  559.         
  560.         var ff_options_serial_createserial = document.getElementById("ff_options_serial_createserial");
  561.         var serial_checked = this.prefNode.getBoolPref("serial.agreed");
  562.         ff_options_serial_createserial.setAttribute("checked", serial_checked);
  563.  
  564.  
  565.         //preselect last tab
  566.         
  567.         var tabbox = document.getElementById("FFOptions"); 
  568.         
  569.         if ( this.prefNode.prefHasUserValue("lasttab") && (window.arguments==undefined || window.arguments=="")) {
  570.  
  571.             
  572.             var lasttabid = this.prefNode.getCharPref("lasttab");
  573.             var lasttab = document.getElementById(lasttabid);
  574.             tabbox.selectedTab = lasttab;
  575.         } else {
  576.             
  577.             try {
  578.                 
  579.                 var lasttab = document.getElementById(window.arguments[0]);
  580.                 tabbox.selectedTab = lasttab;
  581.                 
  582.             } catch (e) {
  583.  
  584.                 footiefox_d(e);
  585.  
  586.             }
  587.         
  588.         }
  589.         
  590.  
  591.  
  592.     }
  593.     
  594.     
  595.     
  596.      function applyLanguagePackage(locale) {
  597.     
  598.     
  599.         var stringbundleDictionary = document.getElementById("stringbundle_dictionary");
  600.         
  601.         stringbundleDictionary.setAttribute("src", "chrome://footiefox/locale/"+locale+"/footiefox/footiefox.properties");
  602.         this.dictionary = document.getElementById("stringbundle_dictionary");
  603.         
  604.          
  605.         var countriesDataBundle = document.getElementById("countries-data-bundle");
  606.         countriesDataBundle.setAttribute("src", "chrome://footiefox/locale/"+locale+"/footiefox/countries.dat");
  607.         
  608.         translate("dialog_options","ff.popupmenu.options", "title");
  609.         
  610.         translate("ff_popupmenu_teamselectionsearchbox_more","ff.popupmenu.more");
  611.         translate("ff_popupmenu_teamselectionfavorites_more","ff.popupmenu.more");
  612.         
  613.         //tab headers
  614.         translate("ff_options_tabs_leagues");
  615.         translate("ff_options_tabs_teams");
  616.         translate("ff_options_tabs_alarm");
  617.         translate("ff_options_tabs_appearance");
  618.         translate("ff_options_tabs_language");
  619.         translate("ff_options_tabs_update");
  620.         
  621.         //leagues tab
  622.         translate("country","ff.options.tabs.leagues");
  623.         translate("ff_options_leagues_headline", null, "value");
  624.         translate("ff_options_leagues_buttons_add");
  625.         translate("ff_options_leagues_buttons_remove");
  626.         translate("ff_options_leagues_buttons_moveup");
  627.         translate("ff_options_leagues_buttons_movedown");
  628.         translate("ff_options_leagues_favoriteleagues_country");
  629.         translate("ff_options_leagues_favoriteleagues_league");
  630.         
  631.         //teams tab
  632.         translate("ff_options_teams_favoriteteams_headline", null, "value");
  633.         translate("ff_options_teams_favoriteteams_results");
  634.         translate("ff_options_teams_buttons_add", "ff.options.leagues.buttons.add");
  635.         translate("ff_options_teams_buttons_remove", "ff.options.leagues.buttons.remove");
  636.         translate("ff_options_teams_buttons_moveup", "ff.options.leagues.buttons.moveup");
  637.         translate("ff_options_teams_buttons_movedown", "ff.options.leagues.buttons.movedown");
  638.         translate("ff_options_teams_favoriteteams_favoriteteams");
  639.         
  640.         
  641.         //alarm tab
  642.         translate("ff_options_alarm_slider_headline");
  643.         translate("ff_options_alarm_activated");
  644.         translate("ff_options_alarm_slider_selectedgame");
  645.         translate("ff_options_alarm_slider_selectedleague");
  646.         translate("ff_options_alarm_slider_allgames");
  647.         translate("ff_options_alarm_slider_duration", null, "value");
  648.         translate("ff_options_alarm_sound_headline");
  649.         translate("ff_options_alarm_sound_activated");
  650.         translate("ff_options_alarm_sound_previewbutton");
  651.         translate("ff_options_alarm_sound_defaultsound");
  652.         translate("ff_options_alarm_sound_customizedsound");
  653.         translate("ff_options_alarm_sound_browsebutton");
  654.         
  655.         
  656.         //appearance tab
  657.         translate("ff_options_appearance_discretemode_headline");
  658.         translate("ff_options_appearance_discretemode_hideif");
  659.         translate("ff_options_appearance_rotation_headline");
  660.         translate("ff_options_appearance_rotation_intervall", null, "value");
  661.         translate("ff_options_appearance_rotation_allmatches");
  662.         translate("ff_options_appearance_rotation_currentleague");
  663.         translate("ff_options_appearance_menulayout_headline");
  664.         translate("ff_options_appearance_menulayout_both");
  665.         translate("ff_options_appearance_menulayout_logos");
  666.         translate("ff_options_appearance_menulayout_titles");
  667.         translate("ff_options_appearance_menulayout_scores");
  668.         translate("ff_options_appearance_menulayout_date");
  669.         translate("ff_options_appearance_scorecolors_headline");
  670.         translate("ff_options_appearance_scorecolors_scheduled", null, "value");
  671.         translate("ff_options_appearance_scorecolors_active", null, "value");
  672.         translate("ff_options_appearance_scorecolors_finished", null, "value");
  673.         
  674.         //language tab
  675.         translate("ff_options_language_package_label");
  676.         translate("ff_options_language_package_description",null,"value");
  677.         translate("ff_options_language_package_contribute",null,"value");
  678.         translate("ff_options_language_partner_label",null,"value");
  679.         translate("ff_options_language_partner_nopartner");
  680.         translate("ff_options_language_partner_propose",null,"value");
  681.         translate("ff_options_language_partner_integration");
  682.         translate("ff_options_language_partner_toolbarbutton",null,"value");
  683.         translate("ff_options_language_partner_statusbar");
  684.         
  685.         //update tab
  686.         translate("ff_options_update_headline");
  687.         translate("ff_options_update_button");
  688.         translate("ff_options_update_description", null, "value");
  689.         translate("ff_options_updateteams_headline");
  690.         translate("ff_options_updateteams_button");
  691.         translate("ff_options_updateteams_description", null, "value");
  692.         translate("ff_options_serial_headline", "ff.wizard.serialpage.label");
  693.         translate("ff_options_serial_createserial", "ff.wizard.serialpage.createserial");
  694.         
  695.       
  696.         
  697.     }
  698.     
  699.     function translate(element_id, dictionary_id, attribute) {
  700.     
  701.         if (attribute == null){
  702.             attribute = "label";
  703.         }
  704.         
  705.         if (dictionary_id == null){
  706.             dictionary_id = element_id.replace(/_/g,".");
  707.         }
  708.     
  709.         try {
  710.             var element = document.getElementById(element_id);
  711.             element.setAttribute(attribute, this.dictionary.getString(dictionary_id));
  712.         } catch (e) {
  713.  
  714.             //d("Failed to translate " + element_id);
  715.         }
  716.     }
  717.  
  718.    
  719.     function onUnload() {
  720.     
  721.         this.myObservers.unregister();
  722.  
  723.  
  724.     }
  725.     
  726.  
  727.     function getAvailableLeagues() {
  728.         //d("getAvailableLeagues");
  729.  
  730.  
  731.         var leaguesDataBundle = null;
  732.         var leaguesDataBundleUpdated = document.getElementById("leagues-data-bundle-updated");
  733.  
  734.         //updated leagues.dat valid
  735.         if ( leaguesDataBundleUpdated.hasAttribute("src") ) {
  736.             leaguesDataBundle = leaguesDataBundleUpdated;
  737.         //updated leagues.dat corrupt, take inbuilt leagues.dat
  738.         } else {
  739.             leaguesDataBundle = document.getElementById("leagues-data-bundle");
  740.         }
  741.  
  742.  
  743.         var availableLeagues = new Array();
  744.  
  745.  
  746.         var leaguesEnum = leaguesDataBundle.strings;
  747.  
  748.         while (leaguesEnum.hasMoreElements()) {
  749.  
  750.             try {
  751.  
  752.                 var element = leaguesEnum.getNext();
  753.  
  754.                 var key = element.QueryInterface(Components.interfaces.nsIPropertyElement).key;
  755.                 var value = element.QueryInterface(Components.interfaces.nsIPropertyElement).value;
  756.  
  757.             } catch(ex){
  758.                 footiefox_d(ex); continue;
  759.             }
  760.  
  761.             var id = key;
  762.             var properties = value.split(":");
  763.  
  764.             var title = properties[0];
  765.             var rank = properties[1];
  766.             var country = properties[2];
  767.             var countryshort = properties[3];
  768.             
  769.             var intltitle = null;
  770.             try {
  771.                 intltitle = properties[4];
  772.                 
  773.                 
  774.             }  catch (e) {footiefox_d(e);}
  775.             
  776.  
  777.  
  778.             var league = new League(id, title, rank, country, countryshort, intltitle);
  779.             availableLeagues.push(league);
  780.         }
  781.  
  782.  
  783.  
  784.         return availableLeagues;
  785.     }
  786.  
  787.     function getAvailableTeams() {
  788.         
  789.             const Ci = Components.interfaces;
  790.             const Cc = Components.classes;
  791.             var sbs = Cc["@mozilla.org/intl/stringbundle;1"].
  792.                getService(Ci.nsIStringBundleService);
  793.             sbs.flushBundles();
  794.             var stringBundle = sbs.createBundle("file://" + ffOptions.tmpDir + "teams.dat");
  795.             
  796.             var teamsDataBundle = null;
  797.             var teamsDataBundleUpdated = document.getElementById("teams-data-bundle-updated");
  798.             
  799.             
  800.             //updated teams.dat valid
  801.             if ( teamsDataBundleUpdated.hasAttribute("src") ) {
  802.  
  803.                 //teamsDataBundle = teamsDataBundleUpdated;
  804.                 teamsDataBundle = stringBundle;
  805.                 
  806.             //updated teams.dat corrupt, take inbuilt teams.dat
  807.             } else
  808.                 teamsDataBundle = document.getElementById("teams-data-bundle");
  809.  
  810.  
  811.             var availableTeams = new Array();
  812.  
  813.             try
  814.             {
  815.                 
  816.                 var teamsEnum = null;
  817.                 try {
  818.                     teamsEnum = teamsDataBundle.getSimpleEnumeration();
  819.                 } catch(e) {
  820.                     
  821.                     teamsEnum = teamsDataBundle.strings;
  822.                 
  823.                 }
  824.  
  825.                 while (teamsEnum.hasMoreElements())
  826.                 {
  827.  
  828.                     var element = teamsEnum.getNext();
  829.                     var key = element.QueryInterface(Components.interfaces.nsIPropertyElement).key;
  830.                     var value = element.QueryInterface(Components.interfaces.nsIPropertyElement).value;
  831.  
  832.                     var id = key;
  833.                     var items = value.split(":");
  834.  
  835.                     var leagueId = items[0];
  836.                     var title = items[1];
  837.  
  838.                     var locName = localizeTeamname(id);
  839.                     
  840.                     if (locName!=null){
  841.                         title = locName;
  842.                         
  843.                     }
  844.                     
  845.                    
  846.                     
  847.                     
  848.                     var team = new Team(id, leagueId, title);
  849.                     availableTeams.push(team);
  850.                 }
  851.             } catch(ex){ footiefox_d(ex) }
  852.             
  853.             return availableTeams;
  854.     }
  855.     
  856.     function localizeTeamname(id) {
  857.     
  858.         var countriesDataBundle = document.getElementById("countries-data-bundle");
  859.    
  860.         var title = null;
  861.         try {
  862.  
  863.             title = countriesDataBundle.getString(id);
  864.                         
  865.         } catch(e) {
  866.             
  867.             return null;
  868.                     
  869.         }
  870.         return title;
  871.  
  872.     
  873.     }
  874.  
  875.     function compareTeams(a, b) {
  876.  
  877.         if (a.title < b.title)
  878.                   return -1;
  879.            if (a.title > b.title)
  880.                   return 1;
  881.  
  882.            return 0;
  883.     }
  884.  
  885.     function sortTeams (teams) {
  886.  
  887.         var sortedTeams = teams.sort(compareTeams);
  888.  
  889.             return sortedTeams;
  890.  
  891.     }
  892.     
  893.  
  894.         function compareLeagues(a, b) {
  895.  
  896.             var countriesDataBundle = document.getElementById("countries-data-bundle");
  897.                 
  898.         try {
  899.             var aTitle = countriesDataBundle.getString(a.country);
  900.         } catch (e) {
  901.                 //d("Failed to translate: " + a.country);
  902.                 return 0;
  903.         }
  904.  
  905.                 try {
  906.             var bTitle = countriesDataBundle.getString(b.country);
  907.         } catch (e) {
  908.                 //d("Failed to translate: " + b.country);
  909.                 return 0;
  910.         }
  911.  
  912.         if (aTitle < bTitle)
  913.                   return -1;
  914.            if (aTitle > bTitle)
  915.                   return 1;
  916.  
  917.         if (a.rank < b.rank)
  918.             return -1;
  919.                 if (a.rank > b.rank)
  920.             return 1;
  921.  
  922.            return 0;
  923.     }
  924.  
  925.  
  926.     function sortLeagues (leagues) {
  927.  
  928.         var sortedLeagues = leagues.sort(compareLeagues);
  929.  
  930.             return sortedLeagues;
  931.  
  932.     }
  933.  
  934.     function getLeaguesByCountry (leagues, country) {
  935.  
  936.  
  937.         var result = new Array();
  938.  
  939.         for (var i=0; i < leagues.length; i++) {
  940.  
  941.             var currentLeague = leagues[i];
  942.  
  943.             if ( currentLeague.country == country )
  944.                 result.push( currentLeague );
  945.  
  946.  
  947.         }
  948.  
  949.         return result;
  950.     }
  951.  
  952.     function removeLeaguesByCountry (leagues, country) {
  953.  
  954.         var result = new Array();
  955.  
  956.         for (var i=0; i < leagues.length; i++) {
  957.  
  958.             var currentLeague = leagues[i];
  959.  
  960.             if ( currentLeague.country != country )
  961.                 result.push(currentLeague);
  962.         }
  963.  
  964.         return result;
  965.     }
  966.  
  967.  
  968.     function populateLeaguesTree ( aLeagues ) {
  969.  
  970.         var availableLeagues = aLeagues;
  971.  
  972.         var leagues = sortLeagues(availableLeagues);
  973.             
  974.         var europeanLeagues = getLeaguesByCountry(leagues, 11316);
  975.         var worldLeagues = getLeaguesByCountry(leagues, 11315);
  976.         var asianLeagues = getLeaguesByCountry(leagues, 11317);
  977.         var northamericanLeagues = getLeaguesByCountry(leagues, 11318);
  978.         var southamericanLeagues = getLeaguesByCountry(leagues, 11319);
  979.         var africanLeagues = getLeaguesByCountry(leagues, 11320);
  980.         var oceanianLeagues = getLeaguesByCountry(leagues, 11321);
  981.  
  982.         var leagues2 = removeLeaguesByCountry (leagues, 11316);
  983.         var leagues3 = removeLeaguesByCountry (leagues2, 11315);
  984.         var leagues4 = removeLeaguesByCountry (leagues3, 11317);
  985.         var leagues5 = removeLeaguesByCountry (leagues4, 11318);
  986.         var leagues6 = removeLeaguesByCountry (leagues5, 11319);
  987.         var leagues7 = removeLeaguesByCountry (leagues6, 11320);
  988.         var leagues8 = removeLeaguesByCountry (leagues7, 11321);
  989.         
  990.         
  991.         addElementsToTree(worldLeagues);
  992.         addElementsToTree(europeanLeagues);
  993.         addElementsToTree(northamericanLeagues);
  994.         addElementsToTree(southamericanLeagues);
  995.         addElementsToTree(asianLeagues);
  996.         addElementsToTree(africanLeagues);
  997.         addElementsToTree(oceanianLeagues);
  998.         
  999.         addElementsToTree(leagues8);
  1000.  
  1001.     }
  1002.  
  1003.  
  1004.     function addElementsToTree (leagues) {
  1005.  
  1006.         var parentTreeChildren = document.getElementById("ff-leagues-treechildren-root");
  1007.         var countriesDataBundle = document.getElementById("countries-data-bundle");
  1008.  
  1009.         var treeItem1 = null;
  1010.  
  1011.         for (var i=0;i < leagues.length; i++)
  1012.         {
  1013.             var currentLeague = leagues[i];
  1014.  
  1015.             var treechildren = document.getElementById(currentLeague.country);
  1016.             
  1017.             if (treechildren == null)
  1018.             {
  1019.  
  1020.                 try {
  1021.                     var translatedCountryName = countriesDataBundle.getString(currentLeague.country);
  1022.                 } catch(e) {
  1023.                     //d("Failed to translate: " + currentLeague.country);
  1024.                 }
  1025.  
  1026.                 treeItem1 = document.createElement("treeitem");
  1027.                 treeItem1.setAttribute("container", "true");
  1028.                 treeItem1.setAttribute("value", currentLeague.country);
  1029.                 parentTreeChildren.appendChild(treeItem1);
  1030.  
  1031.  
  1032.                 var treeCell1 = document.createElement("treecell");
  1033.  
  1034.                 treeCell1.setAttribute("label", translatedCountryName);
  1035.                 
  1036.  
  1037.                 var treeRow1 = document.createElement("treerow");
  1038.  
  1039.                 treeRow1.appendChild(treeCell1);
  1040.                 treeItem1.appendChild(treeRow1);
  1041.  
  1042.                 treechildren = document.createElement("treechildren");
  1043.                 treechildren.setAttribute("id", currentLeague.country);
  1044.                 
  1045.                 treeItem1.appendChild(treechildren);
  1046.  
  1047.             }
  1048.  
  1049.  
  1050.             var treeItem2 = document.createElement("treeitem");
  1051.             treeItem2.setAttribute("value", currentLeague.id);
  1052.             var treeCell2 = document.createElement("treecell");
  1053.             
  1054.             var loc = ffOptions.prefNode.getCharPref("locale");
  1055.             if ((currentLeague.intltitle != null) && (currentLeague.intltitle != "") && (loc != "de-DE")) {
  1056.  
  1057.                 treeCell2.setAttribute("label", currentLeague.intltitle);
  1058.             }else{
  1059.                 treeCell2.setAttribute("label", currentLeague.title);
  1060.             }    
  1061.             var treeRow2 = document.createElement("treerow");
  1062.             treeRow2.appendChild(treeCell2);
  1063.             treeItem2.appendChild(treeRow2);
  1064.             treechildren.appendChild(treeItem2);
  1065.  
  1066.  
  1067.               }
  1068.     }
  1069.  
  1070.  
  1071.     function enableAlarmSoundsGroup(bEnable)
  1072.     {
  1073.  
  1074.  
  1075.         document.getElementById('ff_options_alarm_sound_previewbutton').disabled = !bEnable;
  1076.         var ffAlertSound_sounds_rgroup = document.getElementById('alarm-sounds-rgroup');
  1077.  
  1078.         ffAlertSound_sounds_rgroup.disabled = !bEnable;
  1079.  
  1080.  
  1081.             var ffAlertsoundtype = ffAlertSound_sounds_rgroup.selectedItem.value;
  1082.  
  1083.         if (bEnable) {
  1084.                 if (ffAlertsoundtype=="custom") {
  1085.  
  1086.                 document.getElementById('ff_options_alarm_sound_browsebutton').disabled = false;
  1087.                 document.getElementById('alarm-customfile-tbox').disabled = false;
  1088.             }
  1089.         } else {
  1090.                    document.getElementById('ff_options_alarm_sound_browsebutton').disabled = true;
  1091.             document.getElementById('alarm-customfile-tbox').disabled = true;
  1092.  
  1093.         }
  1094.     }
  1095.  
  1096.     function enableAlarmSliderGroup(bEnable)
  1097.     {
  1098.         document.getElementById('radiogroup-alertmode').disabled = !bEnable;
  1099.  
  1100.     }
  1101.  
  1102.     function ConfigureAlarmPanel(selection)
  1103.     {
  1104.         var alarm_sound_prev_btn = document.getElementById('ff_options_alarm_sound_previewbutton');
  1105.         var alarm_custom_sound_tbox = document.getElementById('alarm-customfile-tbox');
  1106.         var alarm_sound_browse_btn = document.getElementById('ff_options_alarm_sound_browsebutton');
  1107.  
  1108.         if (selection == "standard")
  1109.            {
  1110.             alarm_sound_prev_btn.disabled = false;
  1111.                 alarm_custom_sound_tbox.disabled = true;
  1112.                 alarm_sound_browse_btn.disabled = true;
  1113.         } else if (selection == "custom")
  1114.         {
  1115.             alarm_sound_prev_btn.disabled = false;
  1116.                     if ( alarm_custom_sound_tbox.value=="")
  1117.                         alarm_sound_prev_btn.disabled = true;
  1118.                 else
  1119.                     alarm_sound_prev_btn.disabled = false;
  1120.                     alarm_custom_sound_tbox.disabled = false;
  1121.                 alarm_sound_browse_btn.disabled = false;
  1122.  
  1123.         }
  1124.     }
  1125.  
  1126.  
  1127.  
  1128.  
  1129.     function playSoundURL(sURL_str)
  1130.     {
  1131.  
  1132.             var soundPlayer = Components.classes["@mozilla.org/sound;1"].createInstance();
  1133.         var sample = soundPlayer.QueryInterface(Components.interfaces.nsISound);
  1134.  
  1135.         var ioService = Components.classes["@mozilla.org/network/io-service;1"]
  1136.             .getService(Components.interfaces.nsIIOService);
  1137.         var url = ioService.newURI(sURL_str, null, null);
  1138.         sample.play(url);
  1139.  
  1140.     }
  1141.  
  1142.  
  1143.     function PreviewAlarmSound()
  1144.     {
  1145.  
  1146.       var cuck_sounds_rgroup = document.getElementById('alarm-sounds-rgroup');
  1147.       var sel_option = cuck_sounds_rgroup.selectedItem.value;
  1148.       if (sel_option == "standard")
  1149.        {
  1150.             playSoundURL(this.standardsound);
  1151.  
  1152.        }
  1153.       else if (sel_option == "custom")
  1154.        {
  1155.          var soundfileURL_str = document.getElementById('alarm-customfile-tbox').value;
  1156.  
  1157.          if (soundfileURL_str != "")
  1158.            playSoundURL(soundfileURL_str);
  1159.        }
  1160.  
  1161.     }
  1162.  
  1163.     function browseAlarmSoundFiles()
  1164.     {
  1165.         var nsIFilePicker = Components.interfaces.nsIFilePicker;
  1166.         var fp = Components.classes["@mozilla.org/filepicker;1"]
  1167.                    .createInstance(nsIFilePicker);
  1168.  
  1169.         var dictionary = document.getElementById("stringbundle_dictionary");
  1170.         
  1171.         var customizedFile = "Select file";
  1172.         try {
  1173.             customizedFile = dictionary.getString("ff.options.alarm.sound.selectfile");
  1174.         } catch(e) {
  1175.         
  1176.             footiefox_d(e);
  1177.         }
  1178.         
  1179.         fp.init(window, customizedFile, nsIFilePicker.modeOpen);
  1180.         
  1181.         fp.appendFilter("*.wav","*.wav");
  1182.  
  1183.         var res = fp.show();
  1184.  
  1185.         if (res == nsIFilePicker.returnOK)
  1186.         {
  1187.  
  1188.              document.getElementById("alarm-customfile-tbox").value = fp.fileURL.spec;
  1189.              document.getElementById("ff_options_alarm_sound_previewbutton").disabled = false;
  1190.         }
  1191.  
  1192.     }
  1193.  
  1194.     function onRotationIntervalChanged() {
  1195.  
  1196.         this.rotationIntervalChanged = true;
  1197.  
  1198.     }
  1199.  
  1200.     function doOK() {
  1201.  
  1202.         
  1203.         //remember last tab
  1204.         var tabbox = document.getElementById("FFOptions");
  1205.         this.prefNode.setCharPref("lasttab", tabbox.selectedTab.id);
  1206.  
  1207.         var radiogroupAlertmode = document.getElementById("radiogroup-alertmode");
  1208.  
  1209.         this.prefNode.setCharPref("alertmode", radiogroupAlertmode.selectedItem.value);
  1210.  
  1211.         var showslider = document.getElementById("ff_options_alarm_activated");
  1212.                 this.prefNode.setBoolPref("showslider", showslider.checked);
  1213.  
  1214.                 var durationintervall = document.getElementById("textbox-alertsliderseconds").value;
  1215.                 this.prefNode.setIntPref("sliderdisplayduration", durationintervall);
  1216.  
  1217.                 var discretemode = document.getElementById("ff_options_appearance_discretemode_hideif");
  1218.         this.prefNode.setBoolPref("discretemode", discretemode.checked);
  1219.  
  1220.         var ffAlertsound_cb = document.getElementById("ff_options_alarm_sound_activated");
  1221.           this.prefNode.setBoolPref("playalarm", ffAlertsound_cb.checked);
  1222.  
  1223.         var ffAlertSound_customsound_tbox = document.getElementById("alarm-customfile-tbox");
  1224.         var ffAlertSound_sounds_rgroup = document.getElementById("alarm-sounds-rgroup");
  1225.  
  1226.              var ffAlertsoundtype = ffAlertSound_sounds_rgroup.selectedItem.value;
  1227.  
  1228.  
  1229.  
  1230.         if ( (ffAlertsoundtype == "custom") && (ffAlertSound_customsound_tbox.value == ""))
  1231.               {
  1232.                 var notice ="Please supply a sound file or select default!";
  1233.                 try {
  1234.                     notice = this.dictionary.getString("ff.notice.selectsoundfile");
  1235.                 
  1236.                 } catch (e) {
  1237.                     footiefox_d(e);
  1238.                 }
  1239.                 alert(notice);
  1240.                 return false;
  1241.               }
  1242.         else
  1243.               {
  1244.                 this.prefNode.setCharPref("alarmtype", ffAlertsoundtype);
  1245.  
  1246.                 if (ffAlertsoundtype == "standard")
  1247.                  {
  1248.                        this.prefNode.setCharPref("alarmfile", this.standardsound);
  1249.                  } else if (ffAlertsoundtype == "custom")
  1250.                  {
  1251.                        var ffAlertsoundfile = ffAlertSound_customsound_tbox.value;
  1252.                        this.prefNode.setCharPref("alarmfile", ffAlertsoundfile);
  1253.                  }
  1254.               }
  1255.  
  1256.  
  1257.  
  1258.  
  1259.               var teamsToFollow = "";
  1260.  
  1261.  
  1262.         for (var r=0; r<this.favoriteTeamsList.getRowCount(); r++) {
  1263.                     teamsToFollow = teamsToFollow + this.favoriteTeamsList.getItemAtIndex(r).value + ",";
  1264.         }
  1265.         this.prefNode.setCharPref("teamstofollow", teamsToFollow);
  1266.  
  1267.         var leaguesToFollow = "";
  1268.  
  1269.  
  1270.         var rowcount = this.favoriteLeaguesList.getRowCount();
  1271.     
  1272.     
  1273.     
  1274.         for (var r=0; r< rowcount; r++) {
  1275.                     var currentItem = this.favoriteLeaguesList.getItemAtIndex(r);
  1276.                     
  1277.                     
  1278.                     //var lid = currentItem.value;
  1279.                     var lid = currentItem.getAttribute("value");
  1280.                     
  1281.                     if (lid == "undefined" || lid == undefined) {
  1282.                         footiefox_d(r+": league id undefined");
  1283.                         continue;
  1284.                     }
  1285.                     leaguesToFollow = leaguesToFollow + lid + ",";
  1286.         }
  1287.         
  1288.         
  1289.         
  1290.         this.prefNode.setCharPref("leaguestofollow", leaguesToFollow);
  1291.  
  1292.         var rotationintervall = document.getElementById("textbox-rotation").value;
  1293.  
  1294.         this.prefNode.setIntPref("rotationintervall", rotationintervall);
  1295.  
  1296.         var radiogroupRotationscope = document.getElementById("radiogroup-rotationscope");
  1297.         this.prefNode.setCharPref("rotationscope", radiogroupRotationscope.selectedItem.value);
  1298.  
  1299.         var checkboxmenuitemsshowscores = document.getElementById("ff_options_appearance_menulayout_scores");
  1300.           this.prefNode.setBoolPref("menuitemsshowscores", checkboxmenuitemsshowscores.checked);
  1301.  
  1302.         var checkboxmenuitemsshowdate = document.getElementById("ff_options_appearance_menulayout_date");
  1303.           this.prefNode.setBoolPref("menuitemsshowdate", checkboxmenuitemsshowdate.checked);
  1304.  
  1305.         var radiogroupMenuLayout = document.getElementById("radiogroup-menulayout");
  1306.         this.prefNode.setCharPref("menulayout", radiogroupMenuLayout.selectedItem.value);
  1307.  
  1308.  
  1309.         var textboxScheduled = document.getElementById("textbox-color-scheduled");
  1310.         this.prefNode.setCharPref("color.scheduled", textboxScheduled.value);
  1311.         
  1312.         var textboxActive = document.getElementById("textbox-color-active");
  1313.         this.prefNode.setCharPref("color.active", textboxActive.value);
  1314.         
  1315.         var textboxFinished = document.getElementById("textbox-color-finished");
  1316.         this.prefNode.setCharPref("color.finished", textboxFinished.value);
  1317.         
  1318.         
  1319.         
  1320.         
  1321.         var toolbar_listbox = document.getElementById("ff_options_partner_toolbar_listbox");
  1322.          
  1323.         try {
  1324.             var buttons = "";
  1325.             var cbs = toolbar_listbox.getElementsByTagName("checkbox");
  1326.             
  1327.            for (var i=0; i<cbs.length;i++) {
  1328.                 if (cbs[i].getAttribute("checked")) {
  1329.                     var cb_id = cbs[i].getAttribute("id");
  1330.                     var partner_id = cb_id.split("_")[5];
  1331.                     buttons += partner_id + ":";
  1332.                 }
  1333.             }
  1334.  
  1335.             this.prefNode.setCharPref("partner.toolbarbuttons", buttons);
  1336.  
  1337.         } catch(ex){
  1338.                     footiefox_d(ex); 
  1339.         }
  1340.         
  1341.         
  1342.         
  1343.         var ff_options_serial_createserial = document.getElementById("ff_options_serial_createserial");
  1344.         this.prefNode.setBoolPref("serial.agreed", ff_options_serial_createserial.checked);
  1345.         
  1346.         if (ff_options_serial_createserial.checked && (!this.prefNode.prefHasUserValue("serial.number") || this.prefNode.getCharPref("serial.number")=="") ) {
  1347.         
  1348.             var id="";
  1349.             var c="0123456789abcefghijklmnopqrstuvwxyz";
  1350.             for (var i=0;i<=26;i++) {
  1351.             
  1352.                 id += c.charAt(Math.random()*c.length);
  1353.             }
  1354.             this.prefNode.setCharPref("serial.number", id);
  1355.             
  1356.         }
  1357.         
  1358.         var partner_statusbar = document.getElementById("ff_options_language_partner_statusbar");
  1359.         this.prefNode.setBoolPref("partner.statusbarlabel", partner_statusbar.checked);
  1360.         
  1361.         this.prefNode.setCharPref("partner", this.currentPartner);
  1362.         
  1363.         var dropdown_locale = document.getElementById("menulist_language_package");
  1364.         if (dropdown_locale.selectedItem.value != this.prefNode.getCharPref("locale")) {
  1365.             this.prefNode.setCharPref("locale", dropdown_locale.selectedItem.value);
  1366.             
  1367.             var question = "";
  1368.             try {
  1369.                 question = this.dictionary.getString("ff.notice.restart");
  1370.             
  1371.             } catch(e) {
  1372.                 question = "Changes of the language package come into effect after restarting the browser. Would you like to restart Firefox now?";
  1373.             }
  1374.             
  1375.             var restart = confirm(question);
  1376.             
  1377.             if (restart) {
  1378.                 var appStartup = Components.interfaces.nsIAppStartup;
  1379.                 Components.classes["@mozilla.org/toolkit/app-startup;1"]
  1380.                     .getService(appStartup).quit(appStartup.eRestart | appStartup.eAttemptQuit);
  1381.             }
  1382.         }
  1383.        
  1384.  
  1385.  
  1386.         if (this.favoriteLeaguesChanged) {
  1387.  
  1388.             Components.classes["@mozilla.org/observer-service;1"]
  1389.                  .getService(Components.interfaces.nsIObserverService)
  1390.                  .notifyObservers(null, "footiefoxTriggerUpdate", "");
  1391.  
  1392.         }
  1393.         if (this.rotationIntervalChanged) {
  1394.                     Components.classes["@mozilla.org/observer-service;1"]
  1395.                  .getService(Components.interfaces.nsIObserverService)
  1396.                  .notifyObservers(null, "footiefoxUpdateRotation", "");
  1397.         }
  1398.         
  1399.         
  1400.         Components.classes["@mozilla.org/observer-service;1"]
  1401.                 .getService(Components.interfaces.nsIObserverService)
  1402.                 .notifyObservers(null, "footiefoxOptionsClosed", "");
  1403.  
  1404.         
  1405.         return true;
  1406.  
  1407.     }
  1408.  
  1409.  
  1410.     function addLeaguesToListBox(leaguesToAdd)
  1411.     {
  1412.  
  1413.         var countriesDataBundle = document.getElementById("countries-data-bundle");
  1414.  
  1415.         for (var i=0; leaguesToAdd != "" && i < leaguesToAdd.length; i++)
  1416.         {
  1417.             var league = leaguesToAdd[i];
  1418.             if ( league == null )
  1419.                 continue;
  1420.             
  1421.             //prevent insertion of double items
  1422.             var found = false;
  1423.             var items = this.favoriteLeaguesList.getElementsByTagName("listitem");
  1424.             
  1425.             for ( var x=0; x < items.length; x++ ) {
  1426.                 
  1427.                 if ( "league_id_"+league.id == items[x].id ) {
  1428.                     found = true;
  1429.                     break;
  1430.                 }
  1431.             }
  1432.             
  1433.             
  1434.             if ( !found ) {
  1435.  
  1436.                 var listItem = document.createElement("listitem");
  1437.  
  1438.                 listItem.setAttribute("allowevents", "true");
  1439.                 
  1440.                 listItem.setAttribute("value", league.id);
  1441.                 listItem.setAttribute("id", "league_id_"+league.id);
  1442.  
  1443.                 //footiefox_d("addLeaguesToListBox: "+ league.id);
  1444.  
  1445.                 var countryname = "No name";
  1446.                 try {
  1447.                     countryname = countriesDataBundle.getString(league.country);
  1448.                 } catch(e) {
  1449.                     footiefox_d(e);
  1450.                 }
  1451.                 var countryCell = document.createElement("listcell");
  1452.                 countryCell.setAttribute("label", countryname);
  1453.                 var leagueCell = document.createElement("listcell");
  1454.                 
  1455.                 
  1456.                 var loc = this.prefNode.getCharPref("locale");
  1457.                 if ((league.intltitle != null) && (league.intltitle != "") && (loc != "de-DE")) {
  1458.  
  1459.                     leagueCell.setAttribute("label", league.intltitle);
  1460.                 }else{
  1461.  
  1462.                     leagueCell.setAttribute("label", league.title);
  1463.                 }
  1464.  
  1465.                 listItem.appendChild(countryCell);
  1466.                 listItem.appendChild(leagueCell);
  1467.  
  1468.  
  1469.  
  1470.                 this.favoriteLeaguesList.appendChild(listItem);
  1471.             }
  1472.         }
  1473.  
  1474.  
  1475.     }
  1476.     
  1477.     function updateTeamsSearchList(str) {
  1478.         
  1479.         
  1480.         var teamsSearchList = document.getElementById("ff-teamssearch-list");
  1481.         var count = teamsSearchList.getRowCount();
  1482.         
  1483.         //clear list
  1484.         
  1485.         try {
  1486.             for (var i=0;i<count;i++) 
  1487.                 teamsSearchList.removeItemAt(0);
  1488.         } catch(e) {
  1489.             footiefox_d(e);
  1490.         }
  1491.         
  1492.         if (str == "")
  1493.             return;
  1494.         
  1495.         
  1496.         for (var i=0; i < ffOptions.availableTeams.length; i++)
  1497.         {
  1498.             var currentTeam = ffOptions.availableTeams[i];
  1499.  
  1500.             var currentTitle = currentTeam.title;
  1501.  
  1502.             if (currentTitle.toUpperCase().search(str.toUpperCase())!=-1 ) {
  1503.                 
  1504.                 var listItem = document.createElement("listitem");
  1505.  
  1506.                 listItem.setAttribute("allowevents", "true");
  1507.                 listItem.setAttribute("value", currentTeam.id);
  1508.                 
  1509.                 listItem.setAttribute("context", "menupopup_teamselectionsearchbox");
  1510.                 
  1511.  
  1512.                 var teamCell = document.createElement("listcell");
  1513.                 teamCell.setAttribute("label", currentTitle);
  1514.                 
  1515.                 
  1516.                 
  1517.  
  1518.  
  1519.                 listItem.appendChild(teamCell);
  1520.  
  1521.                 teamsSearchList.appendChild(listItem);
  1522.     
  1523.             }
  1524.  
  1525.         }
  1526.  
  1527.     
  1528.     }
  1529.     
  1530.     function openTeamInformationSearchbox() {
  1531.     
  1532.         var teamsSearchList = document.getElementById("ff-teamssearch-list");
  1533.         
  1534.         var currentItem = teamsSearchList.selectedItem;
  1535.         
  1536.         var teamid = currentItem.value;
  1537.         var url = this.redirectURL+"redirect/"+this.prefNode.getCharPref("partner")+"/10/-1/"+this.prefNode.getCharPref("locale")+"/"+teamid;
  1538.         
  1539.         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  1540.                    .getService(Components.interfaces.nsIWindowMediator);
  1541.         
  1542.         
  1543.         var mainWindow = wm.getMostRecentWindow("navigator:browser");
  1544.         
  1545.         mainWindow.openUILinkIn(url,"tab");
  1546.     
  1547.     }
  1548.     
  1549.     function openTeamInformationFavorites() {
  1550.     
  1551.         var teamsFavoritesList = document.getElementById("ff-favoriteteams-box");
  1552.         
  1553.         var currentItem = teamsFavoritesList.selectedItem;
  1554.         
  1555.         var teamid = currentItem.value;
  1556.         var url = this.redirectURL+"redirect/"+this.prefNode.getCharPref("partner")+"/11/-1/"+this.prefNode.getCharPref("locale")+"/"+teamid;
  1557.         
  1558.         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  1559.                    .getService(Components.interfaces.nsIWindowMediator);
  1560.         
  1561.         
  1562.         var mainWindow = wm.getMostRecentWindow("navigator:browser");
  1563.         
  1564.         mainWindow.openUILinkIn(url,"tab");
  1565.     
  1566.     }
  1567.  
  1568.     function addTeamsToListBox(teamsToAdd) {
  1569.  
  1570.         for (var i=0; teamsToAdd != "" && i < teamsToAdd.length; i++) {
  1571.  
  1572.             var team = teamsToAdd[i];
  1573.             
  1574.             if ( team == null )
  1575.                continue;
  1576.  
  1577.             //prevent insertion of double items
  1578.             var found = false;
  1579.             var items = this.favoriteTeamsList.getElementsByTagName("listitem");
  1580.  
  1581.  
  1582.             try {
  1583.                 for ( var x=0; x < items.length; x++ )
  1584.                     if ( team.id == items[x].value )
  1585.                     found = true;
  1586.             } catch (e) { footiefox_d(e + team ); };
  1587.  
  1588.             if ( !found ) {
  1589.  
  1590.                 var listItem = document.createElement("listitem");
  1591.  
  1592.                 listItem.setAttribute("allowevents", "true");
  1593.                 listItem.setAttribute("value", team.id);
  1594.                 
  1595.                 listItem.setAttribute("context", "menupopup_teamselectionfavorites");
  1596.  
  1597.                 var teamCell = document.createElement("listcell");
  1598.                 teamCell.setAttribute("label", team.title);
  1599.  
  1600.  
  1601.                 listItem.appendChild(teamCell);
  1602.  
  1603.                 this.favoriteTeamsList.appendChild(listItem);
  1604.             }
  1605.         }
  1606.  
  1607.     }
  1608.  
  1609.  
  1610.     function onLeaguesAddCmd()
  1611.     {
  1612.     
  1613.         
  1614.         var countriesDataBundle = document.getElementById("countries-data-bundle");
  1615.         var rangeCount = this.leaguesTree.view.selection.getRangeCount();
  1616.         var addedLocations = new Array();
  1617.  
  1618.         for (var i=0; i < rangeCount; i++)
  1619.         {
  1620.             var start = {};
  1621.             var end = {};
  1622.             this.leaguesTree.view.selection.getRangeAt(i, start, end);
  1623.             for (var c = start.value; c != -1 && c <= end.value; c++)
  1624.             {
  1625.                 var leagueID = this.leaguesTree.view.getItemAtIndex(c).getAttribute("value");
  1626.                 
  1627.  
  1628.                 if (leagueID != null && leagueID != "")
  1629.                 {
  1630.                    
  1631.                     //check if id is country id
  1632.                     try {
  1633.                         
  1634.                         countriesDataBundle.getString(leagueID);
  1635.                         //find all leagues for this country
  1636.                         var leaguesArray = getLeaguesByCountry (this.availableLeagues, leagueID);
  1637.                         for (var ii=0; ii<leaguesArray.length;ii++) {
  1638.                             try {
  1639.                                 var league = leaguesArray[ii];
  1640.                                 
  1641.                                 addedLocations.push(league);
  1642.                             } catch (e) {footiefox_d(e)};
  1643.                         }
  1644.                         
  1645.                     //else add league
  1646.                     } catch(e) {
  1647.                         var league = this.getLeague(leagueID);
  1648.                         addedLocations.push(league);
  1649.                     
  1650.                     }
  1651.                 }
  1652.          
  1653.                 
  1654.             }
  1655.         }
  1656.         
  1657.         this.addLeaguesToListBox(addedLocations);
  1658.         this.favoriteLeaguesChanged = true;
  1659.  
  1660.  
  1661.     }
  1662.  
  1663.     function onTeamsAddCmd()
  1664.     {
  1665.  
  1666.         var teamsSearchList = document.getElementById("ff-teamssearch-list");
  1667.         var addedLocations = new Array();
  1668.  
  1669.         var teamID = teamsSearchList.getSelectedItem(0).getAttribute("value");
  1670.         if (teamID != null && teamID != "") {
  1671.  
  1672.             var team = getTeam(teamID);
  1673.             addedLocations.push(team);
  1674.             
  1675.             this.addTeamsToListBox(addedLocations);
  1676.         }
  1677.  
  1678.     }
  1679.  
  1680.  
  1681.     function leaguesTreeItemClicked (event) {
  1682.  
  1683.                this.onLeaguesAddCmd();
  1684.  
  1685.     }
  1686.  
  1687.     function teamsTreeItemClicked (event) {
  1688.  
  1689.                this.onTeamsAddCmd();
  1690.  
  1691.     }
  1692.  
  1693.  
  1694.     function onLeaguesKeyUp(event) {
  1695.  
  1696.         if (event.keyCode == 46 ) { //Delete key
  1697.                 this.onLeaguesRemoveCmd();
  1698.  
  1699.         }
  1700.  
  1701.     }
  1702.  
  1703.     function onTeamsKeyUp(event) {
  1704.  
  1705.         if (event.keyCode == 46 ) { //Delete key
  1706.                 this.onTeamsRemoveCmd();
  1707.  
  1708.         }
  1709.  
  1710.     }
  1711.  
  1712.  
  1713.         function onLeaguesRemoveCmd()
  1714.     {
  1715.         var remZones = new Array();
  1716.         remZones = remZones.concat(this.favoriteLeaguesList.selectedItems);
  1717.  
  1718.         this.removeLeaguesFavorite(remZones);
  1719.         this.favoriteLeaguesChanged = true;
  1720.  
  1721.  
  1722.  
  1723.     }
  1724.  
  1725.     function onTeamsRemoveCmd()
  1726.     {
  1727.         var remZones = new Array();
  1728.         remZones = remZones.concat(this.favoriteTeamsList.selectedItems);
  1729.  
  1730.         this.removeTeamsFavorite(remZones);
  1731.  
  1732.  
  1733.     }
  1734.  
  1735.  
  1736.     function removeLeaguesFavorite(remZones)
  1737.     {
  1738.  
  1739.         for (var i=0; i < remZones.length ; i++)
  1740.         {
  1741.             var locationIndex = this.favoriteLeaguesList.getIndexOfItem(remZones[i]);
  1742.             this.favoriteLeaguesList.removeItemAt(locationIndex);
  1743.  
  1744.         }
  1745.  
  1746.  
  1747.     }
  1748.  
  1749.         function removeTeamsFavorite(remZones)
  1750.     {
  1751.  
  1752.         for (var i=0; i < remZones.length ; i++)
  1753.         {
  1754.             var locationIndex = this.favoriteTeamsList.getIndexOfItem(remZones[i]);
  1755.             this.favoriteTeamsList.removeItemAt(locationIndex);
  1756.  
  1757.         }
  1758.  
  1759.  
  1760.     }
  1761.  
  1762.  
  1763.     function onLeaguesMoveUpCmd()
  1764.     {
  1765.         var selectedItem = this.favoriteLeaguesList.selectedItem;
  1766.         var prevItem = this.favoriteLeaguesList.getPreviousItem(selectedItem, 1);
  1767.         this.favoriteLeaguesList.insertBefore(selectedItem, prevItem);
  1768.         this.favoriteLeaguesList.selectItem(selectedItem);
  1769.      }
  1770.  
  1771.      function onLeaguesMoveDownCmd()
  1772.     {
  1773.         var selectedItem = this.favoriteLeaguesList.selectedItem;
  1774.         var nextItem = this.favoriteLeaguesList.getNextItem(selectedItem, 1);
  1775.         var nextNextItem = this.favoriteLeaguesList.getNextItem(nextItem, 1);
  1776.         this.favoriteLeaguesList.insertBefore(selectedItem, nextNextItem);
  1777.         this.favoriteLeaguesList.selectItem(selectedItem);
  1778.      }
  1779.      
  1780.      function onTeamsMoveUpCmd()
  1781.     {
  1782.         var selectedItem = this.favoriteTeamsList.selectedItem;
  1783.         var prevItem = this.favoriteTeamsList.getPreviousItem(selectedItem, 1);
  1784.         this.favoriteTeamsList.insertBefore(selectedItem, prevItem);
  1785.                 this.favoriteTeamsList.selectItem(selectedItem);
  1786.      }
  1787.  
  1788.      function onTeamsMoveDownCmd()
  1789.     {
  1790.         var selectedItem = this.favoriteTeamsList.selectedItem;
  1791.         var nextItem = this.favoriteTeamsList.getNextItem(selectedItem, 1);
  1792.                 var nextNextItem = this.favoriteTeamsList.getNextItem(nextItem, 1);
  1793.         this.favoriteTeamsList.insertBefore(selectedItem, nextNextItem);
  1794.         this.favoriteTeamsList.selectItem(selectedItem);
  1795.      }
  1796.     
  1797.     function updateLocale(locale) {
  1798.     
  1799.        
  1800.     
  1801.         var partnerbox = document.getElementById("partner_logo_box");
  1802.         var arrow_left = document.getElementById("autorepeat-left");
  1803.         var arrow_right = document.getElementById("autorepeat-right");
  1804.         var box = document.getElementById("nolocalepartner");
  1805.     
  1806.         var partnersEnum = this.partners.strings;
  1807.         
  1808.         var partnerNum = -1;
  1809.         while (partnersEnum.hasMoreElements()) {
  1810.         
  1811.             try {
  1812.  
  1813.                 var element = partnersEnum.getNext();
  1814.  
  1815.                 var key = element.QueryInterface(Components.interfaces.nsIPropertyElement).key;
  1816.                 var value = element.QueryInterface(Components.interfaces.nsIPropertyElement).value;
  1817.                    
  1818.                 if (value.split(":")[0]==locale) {
  1819.                     partnerNum = key;
  1820.                     break;
  1821.                 }
  1822.  
  1823.             } catch(ex){
  1824.                         footiefox_d(ex); continue;
  1825.             }
  1826.         }
  1827.         
  1828.         //var partner = null;
  1829.  
  1830.         try {
  1831.         //locale partner 
  1832.         
  1833.             box.setAttribute("hidden","true");
  1834.         
  1835.             //check if local partner exists
  1836.             
  1837.             var partner = this.partners.getString(partnerNum);
  1838.             
  1839.             arrow_left.setAttribute("hidden","true");
  1840.             arrow_right.setAttribute("hidden","true");
  1841.             arrow_left.setAttribute("disabled","true");
  1842.             arrow_right.setAttribute("disabled","true");
  1843.         
  1844.         } catch (e) {
  1845.             //no locale partner
  1846.             
  1847.             box.setAttribute("hidden","false");
  1848.             
  1849.         
  1850.             arrow_left.setAttribute("hidden","false");
  1851.             arrow_right.setAttribute("hidden","false");
  1852.             
  1853.             arrow_left.setAttribute("disabled","true");
  1854.             arrow_right.setAttribute("disabled","true");
  1855.             
  1856.             var partnerNum = this.prefNode.getCharPref("partner");
  1857.             
  1858.         
  1859.         }
  1860.         this.currentPartner = partnerNum;
  1861.         partnerbox.setAttribute("src", "chrome://footiefox/skin/"+partnerNum+"/statusbar.png");
  1862.     
  1863.     }
  1864.     
  1865.     function partnerSelect(direction) {
  1866.     
  1867.         var partnerbox = document.getElementById("partner_logo_box");
  1868.         
  1869.         if (direction == "left") {
  1870.             
  1871.             if (this.currentPartner>1) {
  1872.             
  1873.                 var fullpartner = 0;
  1874.                 var nextPartner = parseInt(this.currentPartner);
  1875.                 do {
  1876.                     nextPartner -= 1;
  1877.                     fullpartner = this.partners.getString(nextPartner).split(":")[0].length;
  1878.                 } while( fullpartner == 0 && nextPartner > 1);
  1879.                 
  1880.                 if (fullpartner > 0) {
  1881.                     this.currentPartner = nextPartner;
  1882.                 }
  1883.                 
  1884.                 //var partner = this.partners.getString(this.currentPartner).split(":")[1];
  1885.                 partnerbox.setAttribute("src", "chrome://footiefox/skin/"+this.currentPartner+"/statusbar.png");
  1886.                 
  1887.             }
  1888.             
  1889.         } else {
  1890.         
  1891.                 try {
  1892.                     
  1893.                     var fullpartner = 0;
  1894.                     var nextPartner = parseInt(this.currentPartner);
  1895.                     do {
  1896.                         nextPartner += 1;
  1897.                     
  1898.                         fullpartner = this.partners.getString(nextPartner).split(":")[0].length;
  1899.                         
  1900.                         
  1901.                     } while( fullpartner == 0 && nextPartner <4);
  1902.                     
  1903.                     if (fullpartner > 0) {
  1904.                         this.currentPartner = nextPartner;
  1905.                     }
  1906.                     
  1907.                 } catch (e) {
  1908.                 
  1909.                     footiefox_d("partnerSelect: "+ e );
  1910.  
  1911.                 
  1912.                 }
  1913.                 
  1914.                 partnerbox.setAttribute("src", "chrome://footiefox/skin/"+this.currentPartner+"/statusbar.png");
  1915.                 
  1916.         }
  1917.         
  1918.         
  1919.         var arrowright = document.getElementById("autorepeat-right");
  1920.         try {
  1921.             this.partners.getString(this.currentPartner+1).split(":")[1];
  1922.             arrowright.setAttribute("disabled", "false");
  1923.                     
  1924.         } catch (e) {
  1925.                 
  1926.                     
  1927.             arrowright.setAttribute("disabled", "true");
  1928.                 
  1929.         }
  1930.         
  1931.         var arrowleft = document.getElementById("autorepeat-left");
  1932.         
  1933.         try {
  1934.                     this.partners.getString(this.currentPartner-1).split(":")[1];
  1935.                     arrowleft.setAttribute("disabled", "false");
  1936.                     
  1937.         } catch (e) {
  1938.                 
  1939.                     
  1940.                     arrowleft.setAttribute("disabled", "true");
  1941.                 
  1942.         }
  1943.     
  1944.         
  1945.     
  1946.     }
  1947.  
  1948.  
  1949.  
  1950. };
  1951.  
  1952. function myObservers() {
  1953.  
  1954.     this.register();
  1955. }
  1956.  
  1957. myObservers.prototype = {
  1958.     observe: function(subject, topic, data) {
  1959.  
  1960.     
  1961.  
  1962.         if (topic == "footiefoxTeamsListUpdated") {
  1963.  
  1964.             ffOptions.teamsListUpdated();
  1965.         }
  1966.  
  1967.     },
  1968.     
  1969.     register: function() {
  1970.  
  1971.         var observerService = Components.classes["@mozilla.org/observer-service;1"]
  1972.                           .getService(Components.interfaces.nsIObserverService);
  1973.  
  1974.         observerService.addObserver(this, "footiefoxTeamsListUpdated", false);
  1975.     
  1976.  
  1977.     },
  1978.     
  1979.     unregister: function() {
  1980.             var observerService = Components.classes["@mozilla.org/observer-service;1"]
  1981.                           .getService(Components.interfaces.nsIObserverService);
  1982.  
  1983.         observerService.removeObserver(this, "footiefoxTeamsListUpdated");
  1984.     
  1985.     }
  1986. }
  1987.  
  1988.  
  1989. function inCache(filename) {
  1990.  
  1991.     if (ffOptions.tmpDir == "")
  1992.             return false;
  1993.  
  1994.     try {    
  1995.         var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  1996.         file.initWithPath(ffOptions.tmpDir + filename);
  1997.  
  1998.             if (file.exists())
  1999.                 return true;
  2000.             else
  2001.                 return false;
  2002.     
  2003.     } catch (e) {
  2004.         
  2005.         footiefox_d("Permission missing to access cache directory: "+e);
  2006.         return false;
  2007.     
  2008.     }
  2009.  
  2010. }
  2011.  
  2012.  
  2013. // Dump a message to Javascript Console
  2014. function footiefox_d(msg){
  2015.     var acs = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
  2016.     acs.logStringMessage("FootieFox: " +msg);
  2017. }
  2018.  
  2019.  
  2020. function footiefox_di(msg) {
  2021.         var jetzt = new Date();
  2022.   var zeit = jetzt.getTime();
  2023.   footiefox_d(msg + ": " + zeit);
  2024.  
  2025. }